<!-- 申请企业补充材料 -->
<template>
  <div class="card">
    <div class="card-header">
      <div class="common-sub-title">申请企业补充材料</div>
      <el-button plain @click="handleSave">保存</el-button>
    </div>
    <el-form
      ref="ruleFormRef"
      :model="ruleForm"
      :rules="rules"
      hide-required-asterisk>
      <div>
        <el-form-item label="营业执照" prop="projectContractUrl">
          <Upload text="执照上传" />
        </el-form-item>
        <el-form-item label="法人身份证人像面" prop="bidDocumentUrl">
          <Upload text="人像面上传" />
        </el-form-item>
        <el-form-item label="法人身份证国徽面" prop="letterUrl">
          <Upload text="国徽面上传" />
        </el-form-item>
        <el-form-item label="财务报表" prop="letterUrl">
          <Upload text="报表上传" />
        </el-form-item>
        <el-form-item label="征信报告" prop="letterUrl">
          <Upload text="报告上传" />
        </el-form-item>
      </div>
      <div>
        <el-form-item label="不良记录">
          <el-table :data="ruleForm.badRecordData" border size="small" style="width: 450px;">
            <el-table-column label="不良对象" prop="label" width="140" />
            <el-table-column label="命中次数" width="160"></el-table-column>
            <el-table-column label="涉及金额（万元）"></el-table-column>
          </el-table>
        </el-form-item>
        <el-form-item label="流贷情况">
          <el-table :data="ruleForm.situationData" border size="small" style="width: 450px;">
            <el-table-column label="流贷种类" prop="label" width="100" />
            <el-table-column label="涉及金额（万元）" ></el-table-column>
          </el-table>
        </el-form-item>
      </div>
    </el-form>
  </div>
</template>

<script setup>
import Upload from './upload.vue'
const ruleForm = reactive({
  // 营业执照
  projectContractUrl: '',
  // 法人身份证人像面
  bidDocumentUrl: '',
  // 法人身份证国徽面
  letterUrl: '',
  // 财务报表
  letterUrl: '',
  // 征信报告
  letterUrl: '',
  // 不良记录
  badRecordData: [
    { label: '五年内逾期' },
    { label: '关注及以上类贷款' },
    { label: '展期贷款' },
    { label: '其他不良' }
  ],
  // 流贷情况
  situationData: [
    { label: '短期' },
    { label: '长期' }
  ]
})

const rules = reactive({
  projectContractUrl: [{ required: true, message: '请上传项目合同' }],
  bidDocumentUrl: [{ required: true, message: '请上传招标文件' }],
  letterUrl: [{ required: true, message: '请上传中标通知书' }],
})

// 表单校验
const ruleFormRef = ref(null)
function validateForm() {
  return new Promise((resolve, reject) => {
    ruleFormRef.value.validate(valid => {
      if (valid) {
        resolve(ruleForm)
      }
    })
  })
}

// 保存
function handleSave(){
  validateForm()
  .then(res=>{
    console.log(res,'保存')
  })
}

defineExpose({
  validateForm
})
</script>

<style lang="scss" scoped>
.el-form{
  display: flex;
}
</style>
